//
//  UserInformationViewController.m
//  iMessage
//
//  Created by kare on 14-3-7.
//  Copyright (c) 2014年 kare. All rights reserved.
//

#import "UserInformationViewController.h"

@interface UserInformationViewController ()
@property (nonatomic ,weak) IBOutlet UIView *ui_iconBgView;
@property (nonatomic ,weak) IBOutlet UIView *ui_detailsView;

@property (nonatomic ,weak) IBOutlet UILabel *ui_phoneLab;
@property (nonatomic ,weak) IBOutlet UILabel *ui_registerTimeLab;
@property (nonatomic ,weak) IBOutlet UILabel *ui_zifengLab;
@property (nonatomic ,weak) IBOutlet UILabel *ui_roleLab;
@property (nonatomic ,weak) IBOutlet UILabel *ui_suduLab;

@property (nonatomic ,weak) IBOutlet UILabel *ui_nameLab;

@property (nonatomic ,weak) IBOutlet UISwitch *ui_levleSwitch;
@end

@implementation UserInformationViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self onInitUI];
    [self onReaderLoca];
}

- (void)onInitUI
{
    [[self.ui_iconBgView layer] setCornerRadius:40];
    [[self.ui_iconBgView layer] setBorderWidth:2.0f];
    [[self.ui_iconBgView layer] setBorderColor:[UIColor colorWithWhite:0.88 alpha:1].CGColor];
    
    [[self.ui_detailsView layer] setBorderWidth:1.0f];
    [[self.ui_detailsView layer] setBorderColor:[UIColor colorWithWhite:0.88 alpha:1].CGColor];
}


- (id)onFormNameRaderLoca:(NSString*)_strLocaName
{
   return  [[NSUserDefaults standardUserDefaults] objectForKey:_strLocaName];
}


- (void)onReaderLoca
{
    self.ui_roleLab.text = ([[self onFormNameRaderLoca:@"userLevel"] intValue] == 0 ? @"普通用户" : @"特殊角色");
    
    self.ui_phoneLab.text = [self onFormNameRaderLoca:@"UserMobile"];
    
    self.ui_registerTimeLab.text = [self onFormNameRaderLoca:@"UserRegisterTimer"];
    
    self.ui_nameLab.text = [self onFormNameRaderLoca:@"UserMobile"];
    
    if ([[self onFormNameRaderLoca:@"userLevel"] intValue] == 0)
    {
        self.ui_levleSwitch.hidden = YES;
    }
}

- (IBAction)onChangedSwitch:(id)sender
{
    if ([(UISwitch*)sender isOn])
    {
        NSLog(@"dsfsdf");
        self.ui_suduLab.hidden = NO;
    }
    else
    {
        self.ui_suduLab.hidden = YES;
    }
}

- (IBAction)onExit:(id)sender
{
    if (self.navigationController)
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    else
    {
        [self dismissModalViewControllerAnimated:YES];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end
